from wordpress_project.base.base_page import Tools
import time
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
class adduser_tool(Tools):
    adduser_url = "http://192.168.0.125:9009/wp-admin/user-new.php"
    username_ele = '[name="user_login"]' # 用户名css定位
    email_ele = '[name="email"]' # 电子邮件 css 定位
    adduser_button_ele = '[id="createusersub"]' # 添加按钮的 css 定位
    adduser_success_ele = '[id="message"] p' # 添加成功 之后的断言定位
    adduser_fail_ele = '[class="error"]'  # 添加失败 之后的 断言定位

    def adduser_action(self,adduser,email):
        self.visit(self.adduser_url)
        self.by_css(self.username_ele).send_keys(adduser)
        time.sleep(0.5)
        self.by_css(self.email_ele).send_keys(email)
        time.sleep(0.5)

    def add_a(self):
        self.by_css(self.adduser_button_ele).click()
        time.sleep(0.5)




    def get_success_reg(reg_self):
        return reg_self.by_css(reg_self.adduser_success_ele).text

    def get_fail_reg(reg_self):
        return reg_self.by_css(reg_self.adduser_fail_ele).text


# from selenium import webdriver
# d = webdriver.Chrome()
# a = adduser_tool(driver=d)
# a.adduser_action(adduser='qwe123', email='qwe123@nmsl.com')
# time.sleep(2)